home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / angry / intro.dir / 00001_Script_handlers next >
Text File  |  1999-03-01  |  3KB  |  158 lines

  1.  
  2. global gLoopList
  3. global fileSep
  4.  
  5. on startMovie
  6.   set gLoopList = []  
  7.   --  set the exitLock to TRUE
  8.   initMovie
  9.   repeat with i = 1 to 6
  10.     if soundBusy(i) then sound stop i
  11.   end repeat
  12. end startMovie
  13.  
  14. on initMovie
  15.   if the machineType = 256 then
  16.     put "\" into fileSep
  17.   else  
  18.     put ":" into fileSep
  19.   end if
  20.   
  21.   set the keyDownScript to "keyCheck"
  22.   
  23. end initMovie
  24.  
  25.  
  26. on keyCheck 
  27.   setVolume()
  28. end keyCheck
  29.  
  30.  
  31. on setVolume  
  32.   set inKey = the key
  33.   
  34.   if inKey = "q" OR inKey = "Q" then go to frame "quitArtRight"
  35.   
  36.   if charToNum(inKey) >= charToNum ("0") and charToNum (inKey) <= charToNum ("9") then
  37.     set newVol = integer (the key)
  38.     if the soundLevel <> newVol then set the soundLevel = newVol
  39.   end if  
  40. end setVolume
  41.  
  42.  
  43. on deg2radian thisMany -- convert degrees to radians
  44.   
  45.   return thisMany * ( (2 * pi()) / 360 )
  46.   
  47. end deg2radian
  48.  
  49. on radian2deg thisMany -- convert radians to degrees
  50.   
  51.   return integer(thisMany * ( 360 / (2 * pi()) ))
  52.   
  53. end radian2deg
  54.  
  55.  
  56. on flyGravity theBody, thisMass, thatLoc, thatMass, maxRadius, action
  57.   
  58.   set body1 = theBody
  59.   set mass1 = thisMass
  60.   set gPoint = thatLoc
  61.   
  62.   set gMass = thatMass
  63.   set rMax = maxRadius
  64.   
  65.   set mouseMass = thisMass * 2
  66.   set mouseLoc = point(the mouseH, the mouseV)
  67.   
  68.   set deltaLoc = mouseLoc - the loc of sprite(body1)
  69.   
  70.   set dX = getAt(deltaLoc, 1)
  71.   set dY = getAt(deltaLoc, 2)
  72.   
  73.   set r = sqrt( dX*dX + dY*dY )
  74.   if r = 0  then set r = .01
  75.   
  76.   if r > 60 then set r = 60
  77.   
  78.   set G = 0.01
  79.   
  80.   set F = ( G * mass1 * mouseMass ) / r
  81.   
  82.   -- keep the objects close
  83.   
  84.   if action = "attract" then
  85.     set G = 0.01 * (r * 2.1) 
  86.   else
  87.     if r < rMax then -- if the bat's within rMax of the repulsor
  88.       set G = -0.01 * (r * 2.1)
  89.     else
  90.       set G = 0.0 -- else it has no effect
  91.     end if
  92.   end if
  93.   
  94.   set F = ( G * mass1 * gMass ) / r
  95.   
  96.   set Fx = 0
  97.   set Fy = 0 -- so no <void>s are returned
  98.   
  99.   
  100.   if dX <> 0.0 then
  101.     set Fx = F * dX / r
  102.     if abs( Fx ) > 2000 then
  103.       set Fx = 0.0
  104.     end if
  105.   end if
  106.   
  107.   if dY <> 0.0 then
  108.     set Fy = F * dY / r
  109.     if abs( Fy ) > 2000 then
  110.       set Fy = 0.0
  111.     end if
  112.   end if
  113.   
  114.   return [ #X:Fx, #Y:Fy ]
  115.   
  116. end flyGravity
  117.  
  118.  
  119. on calcGravity theBody, thisMass
  120.   
  121.   set body1 = theBody
  122.   set mass1 = thisMass
  123.   
  124.   set mouseMass = thisMass * 2
  125.   set mouseLoc = point(the mouseH, the mouseV)
  126.   
  127.   set deltaLoc = mouseLoc - the loc of sprite(body1)
  128.   
  129.   set dX = getAt(deltaLoc, 1)
  130.   set dY = getAt(deltaLoc, 2)
  131.   
  132.   set r = sqrt( dX*dX + dY*dY )
  133.   if r = 0  then set r = .01
  134.   
  135.   if r > 60 then set r = 60
  136.   
  137.   set G = 0.01
  138.   
  139.   set F = ( G * mass1 * mouseMass ) / r    
  140.   
  141.   if dX <> 0.0 then
  142.     set Fx = F * dX / r
  143.     if abs( Fx ) > 2000 then
  144.       set Fx = 0.0
  145.     end if
  146.   end if
  147.   
  148.   if dY <> 0.0 then
  149.     set Fy = F * dY / r
  150.     if abs( Fy ) > 2000 then
  151.       set Fy = 0.0
  152.     end if
  153.   end if
  154.   
  155.   return [ #X:Fx, #Y:Fy ]
  156.   
  157. end
  158.